package cn.alm.helloworld.controller;

import dev.langchain4j.model.openai.OpenAiChatModel;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("llm")
public class LLMController {

    @Resource(name = "baocloud")
    private OpenAiChatModel chatModel;

    @GetMapping("chat")
    public String chat(@RequestParam(value = "question", defaultValue = "你是谁？") String question) {
        String chat = chatModel.chat(question);
        return chat;
    }
}
